﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 4. Write a script that finds the lexicographically 
			smallest and largest property in document, window
			and navigator objects -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		var min;
		var max;

		jsConsole.writeLine('-----------------------------------------------------');
		jsConsole.writeLine('-- document');
		jsConsole.writeLine('-----------------------------------------------------');
		findMinMax(document);
		jsConsole.writeLine();

		jsConsole.writeLine('-----------------------------------------------------');
		jsConsole.writeLine('-- window');
		jsConsole.writeLine('-----------------------------------------------------');
		findMinMax(window);
		jsConsole.writeLine();

		jsConsole.writeLine('-----------------------------------------------------');
		jsConsole.writeLine('-- navigator');
		jsConsole.writeLine('-----------------------------------------------------');
		findMinMax(navigator);

		function findMinMax(obj) {
			for (var property in obj) {
				if (min == undefined) {
					min = property;
				}
				else {
					if (property < min) {
						min = property;
					}
				}

				if (max == undefined) {
					max = property;
				}
				else {
					if (property > max) {
						max = property;
					}
				}
			}
			jsConsole.writeLine('object min property = "' + min + '"');
			jsConsole.writeLine('object max property = "' + max + '"');
			min = undefined;
			max = undefined;
		}
	</script>
</body>
</html>
